package com.csun.cmny.provider.utils;

import com.csun.cmny.provider.model.dto.log.UploadAppLogRecordDto;
import com.csun.cmny.util.PublicUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2020-05-19 14:06
 * @Description:
 */
@Slf4j
@Component
public class AppLogUtils {

    public void print(UploadAppLogRecordDto uploadAppLogRecordDto) {

        if (PublicUtil.isEmpty(uploadAppLogRecordDto)) {
            // log为null
            log.warn("=====> app log = upload app log record is null");
        }

        if (PublicUtil.isEmpty(uploadAppLogRecordDto.getLevel())) {
            log.warn("=====> app log = unknow upload app log record");
            uploadAppLogRecordDto.setLevel("unknow");
        }

        switch (uploadAppLogRecordDto.getLevel()) {
            case "debug" :
                log.debug("=====> app log = {}", uploadAppLogRecordDto.toString());
                break;
            case "info" :
                log.info("=====> app log = {}", uploadAppLogRecordDto.toString());
                break;
            case "warn" :
                log.warn("=====> app log = {}", uploadAppLogRecordDto.toString());
                break;
            case "error" :
                log.error("=====> app log = {}", uploadAppLogRecordDto.toString());
                break;
            case "unknow" :
                log.warn("=====> app log = {}", uploadAppLogRecordDto.toString());
                break;
        }

    }

}
